import random

# 定义紫微斗数的主要星曜
major_stars = ["紫微", "天机", "太阳", "武曲", "天同", "廉贞", "天府", "太阴", "贪狼", "巨门", "天相",
               "天梁", "七杀", "破军"]

# 定义十二宫位
zodiac_palaces = ["命宫", "兄弟宫", "夫妻宫", "子女宫", "财帛宫", "疾厄宫", "迁移宫", "交友宫", "事业宫",
                  "田宅宫", "福德宫", "父母宫"]


# 生成命盘函数
def generate_birth_chart():
    birth_chart = {}
    for palace in zodiac_palaces:
        # 每个宫位随机分配 1 - 3 颗星曜
        num_stars = random.randint(1, 3)
        assigned_stars = random.sample(major_stars, num_stars)
        birth_chart[palace] = assigned_stars
    return birth_chart


# 简单的星曜解读字典
star_interpretations = {
    "紫微": "象征着尊贵、权威，在命盘中有此星，往往代表着有领导才能和较高的社会地位。",
    "天机": "主智慧、谋略，拥有此星的人思维敏捷，善于思考和规划。",
    "太阳": "代表光明、活力，命盘中有太阳星，通常意味着个性开朗、积极向上。",
    # 可继续添加更多星曜的解读
}


# 显示命盘及解读函数
def show_birth_chart(birth_chart):
    print("紫微斗数命盘如下：")
    for palace, stars in birth_chart.items():
        print(f"{palace}: {', '.join(stars)}")
        for star in stars:
            if star in star_interpretations:
                print(f"    {star} 解读: {star_interpretations[star]}")
            else:
                print(f"    暂无 {star} 的解读信息。")


# 主游戏函数
def ziwei_game():
    print("欢迎来到紫微斗数游戏！")
    input("请按回车键开始生成命盘...")
    birth_chart = generate_birth_chart()
    show_birth_chart(birth_chart)
    print("游戏结束，感谢参与！")


if __name__ == "__main__":
    ziwei_game()